package _spring_test._tests;

import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;

import java.lang.annotation.*;

/**
 * @Author: huangya
 * @Date: 2019/11/5
 * @Description:
 */
@Component
public class ClassUtilsTest extends BBB<String, Long> implements AAA<Integer, Float> {

    public void fff(){

    }

    /**
     * Type (java.lang.reflect)
     *  --- GenericArrayType (java.lang.reflect) ---
     *  --- ParameterizedType (java.lang.reflect) --- 泛型
     *  --- WildcardType (java.lang.reflect) ---
     *  --- TypeVariable (java.lang.reflect) ---
     *  --- Class (java.lang) --- 类
     *
     * @param args
     * @throws NoSuchMethodException
     */
    public static void main(String[] args) throws NoSuchMethodException {
        System.out.println(ClassUtils.getQualifiedName(Integer.class));
        System.out.println(ClassUtils.getQualifiedName(Integer[].class));
        System.out.println(Integer[].class.getComponentType()); //获取数组类型
        System.out.println(ClassUtils.getQualifiedMethodName(ClassUtilsTest.class.getDeclaredMethod("fff")));
        System.out.println(ClassUtils.getQualifiedMethodName(ClassUtilsTest.class.getDeclaredMethod("fff"), ClassUtilsTest.class));

        ClassUtilsTest classUtilsTest = new ClassUtilsTest();
        System.out.println(classUtilsTest.getClass().getInterfaces());
        System.out.println(classUtilsTest.getClass().getGenericInterfaces()); //带泛型
        System.out.println(classUtilsTest.getClass().getAnnotatedInterfaces());

        System.out.println(classUtilsTest.getClass().getSuperclass());
        System.out.println(classUtilsTest.getClass().getGenericSuperclass()); //带泛型
        System.out.println(classUtilsTest.getClass().getAnnotatedSuperclass());

        System.out.println(classUtilsTest.getClass().getDeclaringClass());
    }
}

@Component
@TestAnnotation
interface AAA<T, T2>{

}

@Component
class BBB<E, E2> extends CCC {

}

@Component
@TestAnnotation
class CCC{

}

@Target(ElementType.TYPE_USE)
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@interface TestAnnotation {

}